package main

import (
	"fmt"
	"errors"
)

var Err1 error=errors.New("err1")
var Err2 error=errors.New("err2")

func p() {
	defer func(){
		if err:=recover(); err!=nil {
			if err==Err1 {
				fmt.Println("catched error:", err)
			} else {
				fmt.Println("rethrow error:", err)
				panic(err)
			}
		}
	}()
	fmt.Println("Start")
	panic(Err2)
	fmt.Println("End")
}

func main() {
	p()
	fmt.Println("Done")
}
